<?php
//公共函数文件
//统一成功返回
function success($msg='',$data=null)
{
    return json([
        'code' => 1,
        'message' => '$msg',
        'data' => $data,
    ]);
}
//统一失败返回
function error($msg='',$data=null)
{
    return json([
        'code' => 0,
        'message' => '$msg',
        'data' => $data,
    ]);
}
//生成随机字符串
function createRandStr($length = 8)
{
    $str = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $randStr = '';
    for($i=0; $i <= $length; $i++){
        $str[mt_rand(0,35)];
    }
    return $randStr;
}